package com.lhd._05mvcboot01.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author lhd
 * @date 2024/4/22
 * @apiNote
 */
@Controller
public class BMIController {
    /**
     * http://localhost:8080/bmi?height=1.75&weight=65
     * @param height
     * @param weight
     * @return
     */
    @RequestMapping(value = "/bmi")
    @ResponseBody
    public String getBMI(double height, double weight) {
        double bmi = weight / (height * height);
        if (bmi < 18.5) {
            return "偏瘦";
        } else if (bmi < 25) {
            return "正常";
        } else if (bmi < 28) {
            return "偏胖";
        } else if (bmi < 32) {
            return "肥胖";
        } else {
            return "严重肥胖";
        }
    }
}
